cmake_minimum_required(VERSION 2.8.0)

# CMake file for Pharoah Design Studio

# Project Name
project( Hieroglyphics )

# CMake module path:
set( CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR} )

# Root directory:
set( ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR} )

# Option to select shared libraries (when possible)
#option( BUILD_SHARED_LIBS "Build shared libraries" ON )
#set( LIB_TYPE STATIC )
#if ( BUILD_SHARED_LIBS )
#    set( LIB_TYPE SHARED )
#endif ( BUILD_SHARED_LIBS )

#Check wxWidgets
#http://docs.wxwidgets.org/2.8/wx_librarieslist.html
#SET(wxWidgets COMPONENTS aui base html adv core propgrid gl stc xml) 
FIND_PACKAGE( wxWidgets COMPONENTS base aui html adv core propgrid gl stc scintilla REQUIRED )
IF(wxWidgets_FOUND)
    INCLUDE( ${wxWidgets_USE_FILE} )
    link_directories( ${wxWidgets_LIB_DIR} )
    IF(UNIX) 
        set(wxWidgets_CXX_FLAGS "`wx-config --cflags -D__WXGTK__  -D_UNICODE`")     
    ENDIF(UNIX)
ENDIF(wxWidgets_FOUND)

# Check FreeType2:
#INCLUDE( FindFreetype )
#FIND_PACKAGE( FREETYPE )
#IF( FREETYPE_FOUND )
#    INCLUDE( ${FREETYPE_INCLUDE_DIRS} )
#    link_directories( ${FREETYPE_LIBRARIES} )
#ENDIF( FREETYPE_FOUND )
FIND_PATH( FREETYPE_INCLUDE ft2build.h )
FIND_FILE( FREETYPE_LIB freetype.lib )

# Reduce pointless warnings in MSVC:
if ( WIN32 AND MSVC )
    add_definitions( -D_CRT_SECURE_NO_WARNINGS )
endif ( WIN32 AND MSVC )

# Make sure that the executable is in a directory where it can access the
# data files.
SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/bin" )
SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE "${CMAKE_SOURCE_DIR}/bin" )
SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_SOURCE_DIR}/bin" ) 

# Add the 'dependencies' sub-directory (this should add the individual dependency packages):
#include( "dependencies/CMakeLists.txt" )
add_subdirectory( dependencies )
include_directories( dependencies )

# Add the main project:

# Add the files individually.  By using glob, the project will not be rebuilt
# when a the CMake file is modified.
# Source files:
set( SOURCES AboutBox.cpp
             ConfigDialog.cpp
             FontDefinition.cpp
             FontsetNotebook.cpp
             FontsetPanelExt.cpp
             Layout.cpp
             MainApplication.cpp
             MainDocument.cpp
             MainFrame.cpp
             MainView.cpp
             PreviewWindow.cpp
             ProjectSettingsDlg.cpp
             StringUtil.cpp
         )

# Header files
set( HEADERS AboutBox.h
             ConfigDialog.h
             FontDefinition.h
             FontsetNotebook.h
             FontsetPanelExt.h
             Layout.h
             MainApplication.h
             MainDocument.h
             MainFrame.h
             MainView.h
             PreviewWindow.h
             ProjectSettingsDlg.h
             StringUtil.h
         )

# Resource files
set( RESOURCES Hieroglyphics.rc )

set( CMAKELISTS ../CMakeLists.txt CMakeLists.txt )
source_group( "CMakeLists" FILES ../CMakeLists.txt )
source_group( "CMakeLists\\src" FILES CMakeLists.txt )

source_group( "Header Files" FILES ${HEADERS} )
source_group( "Source Files" FILES ${SOURCES} )
source_group( "Resource Files" FILES ${RESOURCES} )

# Add the files:
add_executable( Hieroglyphics WIN32
    ${SOURCES}
    ${HEADERS}
    ${RESOURCES}
    ${CMAKELISTS}
)

# Add the wxWidgets libraries for linking
if ( wxWidgets_FOUND )
    TARGET_LINK_LIBRARIES( Hieroglyphics ${wxWidgets_LIBRARIES} )
endif( wxWidgets_FOUND )

# Add the TinyXML library for linking:
# Link to the dependencies:
target_link_libraries( Hieroglyphics TinyXML )

IF ( FREETYPE_INCLUDE )
    include_directories( ${FREETYPE_INCLUDE} )
ENDIF( FREETYPE_INCLUDE )
IF ( FREETYPE_LIB )
    target_link_libraries( Hieroglyphics ${FREETYPE_LIB} )
ENDIF( FREETYPE_LIB )
